import React, { Component } from 'react'

import { connect } from 'react-redux'
import { ADD, REDUCE } from './store/types'
class Page1 extends Component {
    render() {
        return (
            <div>
                <h1>Page1 - {this.props.count}</h1>
                <button onClick={this.props.add}>加 1</button>
                <button onClick={() => { this.props.reduce(3) }}>减 3</button>
            </div>
        )
    }
}


export default connect((state) => {
    return {
        // count: state.app.count
        count: state.getIn(['app', 'count'])
    }
}, (dispatch) => {
    return {
        add() {
            dispatch({ type: ADD })
        },
        reduce(value) {
            dispatch({ type: REDUCE, payload: value })
        }
    }
})(Page1)